<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.global.js'></script>
</head>

<body>
    <div id="app">
        <blog-post 
            @enlarge-text="fontSize += $event" 
            :fs="fontSize" 
            :title="msg">
        </blog-post>
    </div>

    <script>
        const app = Vue.createApp({
            data() {
                return {
                    fontSize: 16,
                    msg: "你妹啊"
                }
            }
        })

        app.component('blog-post', {
            props: ['title', 'fs'],
            emits: ['enlargeText'],
            template: `
                <div class="blog-post">
                    <h4 :style="{fontSize:fs+'px'}">{{ title }}</h4>

                    <!--点击按钮 向父组件发送自定义事件 类型enlargeText 数据0.5 -->
                    <button @click="$emit('enlargeText',0.5)">
                        Enlarge text
                    </button>
                </div>
            `
        })

        const vm = app.mount('#app')
    </script>
</body>

</html>